package com.example.basicdemo2.controller;


import com.isyscore.os.dev.api.common.model.builder.GetAllProvinceRequestBuilder;
import com.isyscore.os.dev.api.common.service.CommonService;
import com.isyscore.os.dev.api.dmc.model.builder.GetAttributeValueRequestBuilder;
import com.isyscore.os.dev.api.dmc.service.DmcService;
import com.isyscore.os.dev.util.IsyscoreHashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/${api-module}/demo")
public class DemoController {

    /**
     * 自动注入设备服务
     */
    @Autowired
    private DmcService dmcService;

    /**
     * 自动注入基础服务
     */
    @Autowired
    private CommonService commonService;


    /**
     * 调用 设备服务-获取设备属性接口
     */
    @GetMapping("bb")
    public String testBb() {
        GetAttributeValueRequestBuilder builder = new GetAttributeValueRequestBuilder();
        IsyscoreHashMap headers = new IsyscoreHashMap();
        headers.put("X-Isyscore-Permission-Sid", "c5a77534-8014-4b2d-9b86-43989f631a0b");
        builder.setHeaders(headers);
        builder.setDevId("testDevId");
        builder.setIdentifier("testId");
        return dmcService.getAttributeValue(builder).getResponse().getBody();
    }

    /**
     * 调用 基础服务-获取所有省份信息接口
     */
    @GetMapping("cc")
    public String testCc() {
        GetAllProvinceRequestBuilder builder = new GetAllProvinceRequestBuilder();
        IsyscoreHashMap headers = new IsyscoreHashMap();
        headers.put("X-Isyscore-Permission-Sid", "c5a77534-8014-4b2d-9b86-43989f631a0b");
        builder.setHeaders(headers);
        return commonService.getAllProvince(builder).getResponse().getBody();
    }


}
